package com.mask.im.business.controller.manage;

import com.mask.im.business.annotation.OptLog;
import com.mask.im.business.model.dto.OperationLogDTO;
import com.mask.im.business.model.vo.ConditionVO;
import com.mask.im.business.common.model.PageResult;
import com.mask.im.business.common.model.RestResponse;
import com.mask.im.business.service.SysOperationLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

import static com.mask.im.business.common.constant.OptTypeConstant.DELETE;

/**
 * 操作日志模块
 *
 * @author jian
 */
@Api(tags = "操作日志模块")
@RestController
public class SysOperationLogController {

    @Resource
    private SysOperationLogService sysOperationLogService;

    @ApiOperation(value = "查看操作日志")
    @GetMapping("/admin/operation/logs")
    public RestResponse<PageResult<OperationLogDTO>> listOperationLogs(ConditionVO conditionVO) {
        return RestResponse.ok(sysOperationLogService.listOperationLogs(conditionVO));
    }

    @OptLog(optType = DELETE)
    @ApiOperation(value = "删除操作日志")
    @DeleteMapping("/admin/operation/logs")
    public RestResponse<?> deleteOperationLogs(@RequestBody List<Integer> operationLogIds) {
        sysOperationLogService.removeByIds(operationLogIds);
        return RestResponse.ok();
    }

}
